<?php
/**
 * Copyright 2008 francissem (http://www.webmoss.net)(francissem@gmail.com)
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 		http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @author francissem
 * @copyright 2008 francissem (http://www.webmoss.net)(francissem@gmail.com)
 * @license http://www.apache.org/licenses/LICENSE-2.0
 */
class Core_System_Logger{

	private $repos;

	function __construct(Core_Repository $repos,$filename="error.log"){
		$this->setRepository($repos,$filename);
	}

	function setRepository(Core_Repository $repos,$key){
		$this->repos=$repos;
		$repos->selectCursor($key);
	}

	function createContentByException(Exception $e){
		$content="";
		$time = date("Y-m-d H:i:s",gmtime()+8*3600);
		$message = $e->getMessage();
		$file = $e->getFile();
		$line = $e->getLine();
		$content .= "Time:     {$time}\n";
		$content .= "File:     {$file}\n";
		$content .= "Line:     {$line}\n";
		$content .= "URL:      {$_SERVER["REQUEST_URI"]}\n";
		$content .= "Message:  {$message}\n";
		$content .= "\n\n";
		return $content;
	}

	function writeException(Exception $e){
		//@todo implement logger write method
		//$this->repos->appendContent($this->createContentByException($e));
	}

}
?>